-
-
Notifications
You must be signed in to change notification settings - Fork 129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support write and read of boolean masks in wcs1d-fits
#1051
Conversation
@rosteen do PRs need extra approval for the CI? |
They shouldn't, since you've contributed here before. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
Actions was having problem. I am going to try to close/re-open. |
If CI does not kick off still, maybe just wait out the server problems. https://www.githubstatus.com/ |
And I could even trigger Extra CI :) but workflows still seem to be clogged... |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1051 +/- ##
=======================================
Coverage ? 70.29%
=======================================
Files ? 64
Lines ? 4410
Branches ? 0
=======================================
Hits ? 3100
Misses ? 1310
Partials ? 0 ☔ View full report in Codecov by Sentry. |
to write out fitted cube. Need astropy/specutils#1051 [ci skip] [rtd skip]
Not quite there. Looks like flux is written to EXT 0 even when there is mask, which is super confusing. Usually when there are multiple data extensions, EXT 0 is primary. Let's see this example: import numpy as np
from astropy import units as u
from astropy.io import fits
from astropy.wcs import WCS
from specutils import Spectrum1D
w = WCS(naxis=3)
w.wcs.ctype = 'FREQ', 'DEC--TAN', 'RA---TAN'
w.wcs.set()
sp = Spectrum1D(flux=np.ones((8, 9, 10)) * u.nJy, mask=np.zeros((8, 9, 10), dtype=np.int8), wcs=w)
sp.write("ztmp.fits", format="wcs1d-fits", overwrite=True)
fits.info("ztmp.fits") With this patch, I get this:
But I want this:
|
to write out fitted cube. Need astropy/specutils#1051 [ci skip] [rtd skip]
Yes, if you want the flux written to a different extension, you need to specify (e.g.) |
But this is not how 90% of the data out there are laid out. I have never seen a real life example where the FLUX is still in primary extension if there are ERR or DQ tied to it. |
The SDSS |
What do the other specutils maintainers think?
Yes, I think it is common to have the |
I've changed the order; when updating the tests I realised that the current |
to write out fitted cube. Need astropy/specutils#1051 [ci skip] [rtd skip]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to pass in extra options (hdu=1, flux_name="SCI"
) to make an existing test pass over at spacetelescope/jdaviz#2094 but it is not the end of the world.
LGTM. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code looks fine to me, thanks!
Please give me a ping when this ends up in a released version, so I can follow up over at Jdaviz to use this for Cubeviz. Thanks! |
to write out fitted cube. This uses astropy/specutils#1051 Update specutils pin.
When is the next release for specutils? |
* Test warning on unspecified uncertainty type * Store and retrieve boolean masks in wcs1d-fits * Move uncertainty before mask in hdulist
to write out fitted cube. This uses astropy/specutils#1051
to write out fitted cube. This uses astropy/specutils#1051
This PR includes a test that was missed before merging #1009 and adds functionality to write
Spectrum1D
masks ofdtype = bool
in WCS1D format, resolving an issue that came up in #1009 (comment).As
bool
orbit
cannot be written natively to FITS, enabling round-tripping requires encoding the original type, for which there also seems to be no standard. I propose to introduce the header keyword 'BFORM', which is neither defined nor reserved in the FITS standard, and use it analogously to 'TFORMn' in BINTABLE extensions, for which these values are allowed (excerpt):Here
BFORM
is only used for the 1-bit types, as other formats are already recognised, but it might be added for others for consistency.